using AspNetMvc.Models;
using AspNetMvc.Services.Events.Interfaces;

namespace AspNetMvc.Helpers
{
   internal class EventDateTimeListsHelper
   {
      public static void FillForCreating(EventForEditing viewEvent,
         IEventHoursListService eventHoursListService,
         IEventMinutesListService eventMinutesListService)
      {
         viewEvent.StartHoursList = eventHoursListService.GetHoursList();
         viewEvent.StartMinutesList = eventMinutesListService.GetMinutesList();
         viewEvent.EndHoursList = eventHoursListService.GetHoursList();
         viewEvent.EndMinutesList = eventMinutesListService.GetMinutesList();
      }

      public static void FillForEditing(EventForEditing viewEvent,
   IEventHoursListService eventHoursListService,
   IEventMinutesListService eventMinutesListService)
      {
         viewEvent.StartHoursList = eventHoursListService.GetHoursList(viewEvent.Event.StartDateTimeOffset.Hour);
         viewEvent.StartMinutesList = eventMinutesListService.GetMinutesList(viewEvent.Event.StartDateTimeOffset.Minute);

         viewEvent.EndHoursList = viewEvent.Event.EndDateTimeOffset.HasValue ? 
            eventHoursListService.GetHoursList(viewEvent.Event.EndDateTimeOffset.Value.Hour) : 
            eventHoursListService.GetHoursList();
         viewEvent.EndMinutesList = viewEvent.Event.EndDateTimeOffset.HasValue ? 
            eventMinutesListService.GetMinutesList(viewEvent.Event.EndDateTimeOffset.Value.Minute) :
            eventMinutesListService.GetMinutesList();
      }
   }
}